 class DateUtils {
    formatDate(formatStr, fTime) {
        var fStr = 'ymdhis';
        var month = fTime.getMonth() + 1;
        var day = fTime.getDate();
        var hours = fTime.getHours();
        var minu = fTime.getMinutes();
        var second = fTime.getSeconds();
        month = month < 10 ? '0' + month : month;
        day = day < 10 ? '0' + day : day;
        hours = hours < 10 ? ('0' + hours) : hours;
        minu = minu < 10 ? '0' + minu : minu;
        second = second < 10 ? '0' + second : second;
        var formatArr = [
            fTime.getFullYear().toString(),
            month.toString(),
            day.toString(),
            hours.toString(),
            minu.toString(),
            second.toString()
        ]
        for (var i = 0; i < formatArr.length; i++) {
            formatStr = formatStr.replace(fStr.charAt(i), formatArr[i]);
        }
        return formatStr;
    }


    //日期格式化
    formatDateFromStr(formatStr, fdate) {
        if (fdate) {
            if (~fdate.indexOf('.')) {
                fdate = fdate.substring(0, fdate.indexOf('.'));
            }
            fdate = fdate.toString().replace('T', ' ').replace(/\-/g, '/');
            var fTime;
            if (!formatStr)
                formatStr = "y-m-d h:i:s";
            if (fdate)
                fTime = new Date(fdate);
            else
                fTime = new Date();

            return this.formatDate(formatStr, fTime);
        } else {
            return "";
        }
    }
} 
export default new DateUtils();